import datetime

from django.db import models

# Create your models here.
import time

"""
2.数据库迁移：python manage.py makemigrations
生成迁移文件，这一步执行之后是不会有数据库表的生成的
3.生成表：python manage.py migrate

"""


# 文本上传的模型类
class Text_uploadModel(models.Model):
    username = models.CharField(verbose_name="用户名",max_length=32,null=True)
    time = models.DateTimeField(verbose_name="插入时间",null=True)
    information = models.CharField(verbose_name="文本信息",max_length=64,null=True)
    ip = models.CharField(verbose_name="ip地址",max_length=64,null=True)
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除', help_text='逻辑删除')

    class Meta:
        db_table = "text_upload"
        verbose_name = "文本信息"
        verbose_name_plural = verbose_name

    def delete(self, using=None, keep_parents=False):
        """重写数据库删除方法实现逻辑删除"""
        self.is_delete = True
        self.save()


# 图片上传模型类
class Imgs_uploadModel(models.Model):
    username = models.CharField(verbose_name="用户名", max_length=32, null=True)
    time = models.DateTimeField(verbose_name="插入时间", null=True)
    image = models.ImageField(verbose_name="图片",upload_to="imgs/",default=None,null=True)
    image_name = models.CharField(verbose_name="图片名称",max_length=64,default=None)
    ip = models.CharField(verbose_name="ip地址", max_length=64, null=True)
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除', help_text='逻辑删除')

    class Meta:
        db_table = "img_upload"
        verbose_name = "图片信息"
        verbose_name_plural = verbose_name
